var component = {};
component.dialog = {};
component.dialog.isOpen = function() {
	if((typeof win)=="undefined"){
		return false;
	}else if((typeof win)=="object"){
		return win.dialog('isOpen');
	}
	return false;
};
component.dialog.clear = function(obj){
	$(obj).parent().find('input[type!="button"]').val('');
};
component.dialog.returnValue = function(return_text, return_value) {
	var returnValueId = jQuery('#returnValueID').val();
	var returnValueText = jQuery('#returnValueText').val();
	var text = jQuery(window.parent.document).find("#" + returnValueText);
	var value = jQuery(window.parent.document).find("#" + returnValueId);
	text.attr('value', return_text);
	value.attr('value', return_value);
	parent.component.dialog.closeWindow();
};
component.dialog.closeWindow = function() {
	win.dialog('close');
};

/*
 * 带returnValue的弹窗
 */
component.dialog.popWindow = function(obj) {
		obj = jQuery(obj);
		var param = obj.attr('parameter');
		param = jQuery.parseJSON(param);
		var page = param.src;
		var value_id = obj.attr('value_id');
		var text_id = obj.attr('id');
		if (value_id && text_id) {
			page = page + (page.indexOf("?") > 0 ? "&" : "?") + "value_id="
					+ value_id + "&text_id=" + text_id;
		component.dialog.popDialog(page, param);
	}
};

// 在iframe中弹出页面
component.dialog.popDialog = function(page, param) {
	if (this.isOpen()) {
		return ;
	}
	win = jQuery('<div id="pop_windows"></div>');
	win.dialog({
		modal:true,
		autoOpen : false
	});
	win.dialog(param);
	
	frame = jQuery('<iframe frameborder=0 style="border: 0px;height:100%;width:100%" src="'
			+ page + '"></iframe>');
	frame.hide();
	progress = jQuery('<div  id="progressBar" class="progressBar"><img  width="100%"   src="img/loading_big.gif"/></div>');
	win.append(progress);
	win.append(frame);
	win.dialog('open');

	frame.bind('load', function() {
		progress.hide();
		frame.fadeIn();
		contentHeight = frame.contents().outerHeight();
		contentWidth = frame.contents().outerWidth();
		frame.height(win.innerHeight()-12);
		frame.width(win.innerWidth()-26);

	});


	progress.css({
		'position' : 'absolute ',
		'padding-top' : function() {
			return (win.height() - progress.height()) / 2;
		}
	});
};

component.table = {};
component.table.eidtRow = function(row_id) {
	// 在调用页面中实现
	alert('修改row_id:' + row_id);
};
component.table.deletRow = function(row_id) {
	// 在调用页面中实现
	alert('删除row_id:' + row_id);
};

component.datePicker = function(id) {
	var target = jQuery('#' + id);
	target.datepicker({
		dateFormat : 'yy-mm-dd',
		showAnim : "slide",
		changeMonth : true,
		changeYear : true,
		showWeek : true,
		showButtonPanel : true,
		closeText : 'close',
		yearRange : '1912:2012'
	});
}

component.tree={};
component.tree.treeNodeOnclick=function (event){
	alert($(event.target).text());
}